package com.qidianit.mes.device.controller;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.DeviceTypeVO;
import com.qidianit.mes.pojo.Process;
import com.qidianit.mes.device.service.DeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/devicetype")
@CrossOrigin
public class DeviceTypeController {
    @Autowired
    private DeviceTypeService processService;
    @GetMapping("/list")
    public MESResult list(String deviceTypeName,Boolean isEnabled,String parentCode,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10")int limit) {
            MESResult mesResult = processService.queryProcess(deviceTypeName, isEnabled,parentCode, page, limit);
        return mesResult;
    }
    @GetMapping("/listByParentId")
    public MESResult listById(String parentCode){
        MESResult mesResult = processService.selectByParentCode(parentCode);
        return mesResult;
    }

    @PostMapping("/add")
    public MESResult addNewDeviceType(@RequestBody DeviceTypeVO deviceTypeVO){
        return processService.addDeviceType(deviceTypeVO);
    }
    @GetMapping("/addSon")
    public MESResult addNewDeviceTypeSon(DeviceTypeVO deviceTypeVO,String parentCode){
        return processService.addDeviceTypeSon(deviceTypeVO,parentCode);
    }

    @PostMapping("/edit")
    public MESResult editDeviceType(@RequestBody DeviceTypeVO deviceTypeVO){
        return processService.editDeviceType(deviceTypeVO);
    }
    @DeleteMapping("/delete")
    public MESResult deleteProcess(String deviceTypeCode){
        return processService.deletedeviceType(deviceTypeCode);
    }
}
